<?php
require('config.php');
$link = mysql_connect($config['mysql_host'], $config['mysql_username'], $config['mysql_password']);
mysql_select_db($config['mysql_database']);
$image = (int) $_GET['image'];
$result = mysql_query('select * from images where image_id="'.$image.'"');
if(mysql_num_rows($result) == 0)
{
	die('Error');
}
else
{
	$image_data = mysql_fetch_assoc($result);
	header('Content-type: image/png');
	readfile('images/'.$image_data['image_name']);
}
mysql_close($link);
?>